﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;


namespace UnisysMassiveImporter_v2.Entidades.Configuracion
{
    public class Configuration
    {
        public bool historyGeneration { get; set; } //colocar si se crea o no historial de expedientes procesados
        public String fileSystemHistory { get; set; }
        
        public String logLocation { get; set; }//en caso de crear logs donde colocar los archivos
        public String config_threadLocation { get; set; }//donde se encuentran los archivos de configuracion de los hilos
        
        public System.Collections.ArrayList emailAccountTo { get; set; }
        
        public int logSize { get; set; }
        public String fileSystemError { get; set; }
        public string system { get; set; }
        public int maxFiles { get; set; }

        public static Configuration Load()
        {
          try
            {
                
                Configuration Configuration = new Configuration();
                //cargar app config...
                Configuration.historyGeneration = Boolean.Parse(ConfigurationManager.AppSettings["GenerarHistorico"].ToString());

                Configuration.fileSystemHistory = ConfigurationManager.AppSettings["FileSystemHistory"].ToString();

                Configuration.fileSystemError = ConfigurationManager.AppSettings["FileSystemError"].ToString();

                Configuration.logLocation = ConfigurationManager.AppSettings["DireccionLog"].ToString();

                Configuration.config_threadLocation = ConfigurationManager.AppSettings["Threads_Configurations"].ToString();
                

                String[] correos = ConfigurationManager.AppSettings["EMailAccountTo"].ToString().Split(',');
                System.Collections.ArrayList emails = new System.Collections.ArrayList();
                foreach (String n in correos)
                {
                    emails.Add(n);
                }

                Configuration.emailAccountTo = emails;
            

                Configuration.logSize = Convert.ToInt32(ConfigurationManager.AppSettings["LogSize"]);

                
                Configuration.system = ConfigurationManager.AppSettings["System"].ToString();
                return Configuration;
            }
            catch (Exception e)
            { throw new Exception(e.Message); }
        }
    }
}
